import HTTP from '../http.js'
const ERR_OK = 200
class detailAPi extends HTTP{
    constructor() {
        super()
        this.getOpenID((openid) => {
            this.openid = openid
        })
    }
    getItemDetail(course_id) {
        return new Promise((resolve, reject) => {
            this.request({
                url: '/home/course/courseInfo',
                method: 'get',
                data: { course_id, openid: this.openid }
            })
            .then(res => {
                if (res.code === ERR_OK) {
                    console.log(res)
                    resolve(res.data)
                }
            })
            .catch(err => {
                console.log(err)
            })
        })
    }
    getOpenID(fn) {
        wx.getStorage({
            key: 'openid',
            success (res) {
              console.log(res.data)
              fn && fn(res.data)
            }
          })
    }
    
    
}
export  default detailAPi 